package com.yxy.controller.user;

import com.yxy.common.PageResult;
import com.yxy.common.Result;
import com.yxy.constant.RequestMapperConstant;
import com.yxy.pojo.dto.HotelPageQueryDTO;
import com.yxy.pojo.dto.HotelSpecsPageQueryDTO;
import com.yxy.pojo.vo.HotelVO;
import com.yxy.service.HotelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController("userHotelController")
@RequestMapping(RequestMapperConstant.USER_REQUEST_MAPPER + "hotel")
@Slf4j
public class HotelController {

    @Autowired
    private HotelService hotelService;

    /**
     * 分页查询酒店信息
     * @param hotelPageQueryDTO
     * @return
     */
    @GetMapping("/page")
    public Result<PageResult> page(HotelPageQueryDTO hotelPageQueryDTO){
        log.info("分页查询酒店信息：{}", hotelPageQueryDTO);
        PageResult result = hotelService.advancedPageQuery(hotelPageQueryDTO);
        return Result.success("", result);
    }

    /**
     * 获取酒店区域列表
     * @return
     */
    @GetMapping("/getHotelArea")
    public Result<Map<String, List<String>>> getHotelArea(){
        log.info("获取酒店区域列表");
        Map<String, List<String>> result = hotelService.getHotelArea();
        return Result.success("", result);
    }


    /**
     * 分页查询酒店规格信息
     * @param hotelSpecsPageQueryDTO
     * @return
     */
    @GetMapping("/pageQuerySpecs")
    public Result<PageResult> pageQuerySpecs(HotelSpecsPageQueryDTO hotelSpecsPageQueryDTO){
        log.info("分页查询酒店规格信息：{}", hotelSpecsPageQueryDTO);
        PageResult pageResult = hotelService.pageQuerySpecs(hotelSpecsPageQueryDTO);
        return Result.success("", pageResult);
    }

    /**
     * 根据id查询酒店信息
     * @param id
     * @return
     */
    @GetMapping("/getHotelById")
    public Result<HotelVO> getHotelById(int id){
        log.info("根据id查询酒店信息：{}", id);
        HotelVO hotelVO = hotelService.getHotelById(id);
        return Result.success("", hotelVO);
    }
}
